<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- 导入依赖 -->
    <script src='https://unpkg.com/@antv/l7'></script>
    <script src="https://lib.baomitu.com/jquery/2.2.4/jquery.js"></script>
    <script src="https://lib.baomitu.com/jquery/2.2.4/jquery.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0
        }

        #map {
            position: absolute;
            top: 0;
            right: 0;
            bottom: 0;
            left: 0;
            background-color: rgba(255, 0, 0, 0.565);
        }
    </style>
</head>

<body>
    <div id="map">

    </div>
    <script>
        /* Scene场景 -L7不提供地图,只专注于地理数据可视化
        Scene 
        1、Map
        2、Layer
         */
        const scene = new L7.Scene({
            /* 设置场景的挂载点 */
            id: "map",
            map: new L7.GaodeMap({
                style: "dark",
                center: [114.40088809833583,
                    30.4663210497187],
                pitch: 60,
                /* zoom可以实现放大和缩小级别 */
                zoom: 14
            }),
            logoVisible: false
        })
        let url = 'http://39.103.151.139:8000/gis/zhongdi'
        $.ajax({
            url,
            success: data => {
                console.log(data);
                let zhongdi_layer = new L7.PolygonLayer();
                zhongdi_layer.source(data)
                    .shape("extrude")
                    .size("people", p => {
                        return p / 20
                    })
                    .color("#652e80")
                    .active(true)
                scene.addLayer(zhongdi_layer);
                /* 点击事件弹窗信息 */
                zhongdi_layer.on("click", evt => {
                    console.log(evt);
                    var lngLat = evt.lngLat;
                    const { name, people } = evt.feature.properties;
                    const popup = new L7.Popup({
                        lngLat,
                        html: `<span>公司名称:${name}</span>`
                    })
                    scene.addPopup(popup);
                })
            }
        })
    </script>
</body>

</html>